<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>社区注册 - 居民管理系统</title>
    <!-- 引入Bootstrap美化界面 -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- 引入Bootstrap图标 -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
    <style>
        :root {
            --primary-color: #3498db;
            --secondary-color: #2c3e50;
            --card-shadow: 0 4px 12px rgba(0,0,0,0.1);
        }
        body {
            background: linear-gradient(135deg, #f5f7fa, #e4e7eb);
            min-height: 100vh;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            display: flex;
            align-items: center;
            padding: 20px 0;
        }
        .register-card {
            background: white;
            border-radius: 12px;
            box-shadow: var(--card-shadow);
            overflow: hidden;
            transition: transform 0.3s ease;
        }
        .register-card:hover {
            transform: translateY(-5px);
        }
        .register-header {
            background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
            color: white;
            padding: 30px 20px;
            text-align: center;
        }
        .register-form {
            padding: 30px;
        }
        .form-icon {
            position: absolute;
            left: 15px;
            top: 50%;
            transform: translateY(-50%);
            color: #6c757d;
            z-index: 5;
        }
        .form-control {
            padding-left: 40px;
            height: 50px;
            border-radius: 8px;
            border: 1px solid #e1e5eb;
            transition: all 0.3s;
        }
        .form-control:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 0.25rem rgba(52, 152, 219, 0.25);
        }
        .btn-register {
            background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
            border: none;
            height: 50px;
            font-size: 1.1rem;
            font-weight: 600;
            border-radius: 8px;
            transition: all 0.3s;
        }
        .btn-register:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
        }
        .error-message {
            background-color: #f8d7da;
            color: #721c24;
            padding: 15px;
            border-radius: 8px;
            margin-bottom: 20px;
            border-left: 4px solid #dc3545;
        }
    </style>
</head>

<body>
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-6 col-lg-5">
            <div class="register-card">
                <div class="register-header">
                    <h2><i class="bi bi-person-plus"></i> 创建账户</h2>
                    <p class="mb-0">加入社区管理系统，开启便捷生活</p>
                </div>

                <div class="register-form">
                    <% if (request.getAttribute("error") != null) { %>
                    <div class="error-message">
                        <i class="bi bi-exclamation-circle"></i> <%= request.getAttribute("error") %>
                    </div>
                    <% } %>

                    <form action="register" method="post">
                        <div class="mb-4 position-relative">
                            <label for="role" class="form-label fw-bold">角色选择</label>
                            <div class="input-group">
                                <span class="input-group-text bg-light border-end-0">
                                    <i class="bi bi-people"></i>
                                </span>
                                <select id="role" name="role" class="form-select" required>
                                    <option value="admin">管理员</option>
                                    <option value="resident" selected>居民</option>
                                </select>
                            </div>
                        </div>

                        <div class="mb-4 position-relative">
                            <label for="username" class="form-label fw-bold">用户名</label>
                            <i class="bi bi-person form-icon"></i>
                            <input type="text" id="username" name="username" class="form-control"
                                   placeholder="请输入用户名" required>
                        </div>

                        <div class="mb-4 position-relative">
                            <label for="password" class="form-label fw-bold">密码</label>
                            <i class="bi bi-lock form-icon"></i>
                            <input type="password" id="password" name="password" class="form-control"
                                   placeholder="请输入密码" required>
                        </div>

                        <button type="submit" class="btn btn-register w-100 text-white">
                            <i class="bi bi-check-circle me-2"></i> 立即注册
                        </button>

                        <div class="mt-4 text-center">
                            <p class="mb-0">已有账户? <a href="#" class="text-decoration-none fw-bold">立即登录</a></p>
                        </div>
                    </form>
                </div>
            </div>

            <div class="mt-4 text-center text-muted">
                <small>© 2025 社区管理系统 | 居民服务平台</small>
            </div>
        </div>
    </div>
</div>

<!-- 引入Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>